package c04.monitor;

import lombok.extern.slf4j.Slf4j;

@Slf4j(topic = "c.WaitTest")
public class WaitTest {
    static final Object lock = new Object();

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            synchronized (lock) {
                log.debug("t1 begin");
                try {
                    lock.wait();  //只有加锁对象才可以调用wait方法
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "t1");

        log.debug("{}", t1.getState());

        t1.start();

        log.debug("{}", t1.getState());
    }
}
